/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dnbW.uiW.dbW;


import java.io.File;
import java.util.ArrayList;
import java.util.List;


/**
 *
 * @author zhouyong
 */
public class AddDocumentTask {

    private List<File> fileList = new ArrayList<File>();
    private File file;
    private String dataSourceName;

    public AddDocumentTask( File file) {
        //super(application);
        fileList.add(file);
        //setTitle("Load Document");
        //setUserCanCancel(false);
    }

    public AddDocumentTask(List<File> files) {
        //super(application);
        fileList.addAll(files);
//        setTitle("Load Documents");
//        setUserCanCancel(false);
    }

    public AddDocumentTask( File file, String dataSourceName) {
        //super(application);
        fileList.add(file);
        this.dataSourceName = dataSourceName;
//        setTitle("Load Document");
//        setUserCanCancel(false);
    }

    public AddDocumentTask( List<File> files, String dataSourceName) {
        //super(application);
        fileList.addAll(files);
        this.dataSourceName = dataSourceName;
        //setTitle("Load Documents");
        //setUserCanCancel(false);
    }
    
//    @Override
//    protected void failed(Throwable arg0) {
//        super.failed(arg0);
//        setMessage("Document Loading Failed...(" + file.getAbsolutePath() + ")");
//    }
//
//    @Override
//    protected void succeeded(Void arg0) {
//        super.succeeded(arg0);
//        setMessage("Document Loaded Successfully...(" + file.getAbsolutePath() + ")");
//    }
//
//    @Override
//    protected Void doInBackground() throws Exception {
//        DatabaseController dbController = DNB.getDatabaseController();
//        if (fileList.size() == 1) {
//            file = fileList.get(0);
//            setMessage("Loading document from: " + file.getAbsolutePath());
//            dbController.addDocument(dbController.getCurrentDb(), file, dataSourceName);
//        }
//        else{
//            for(File dataFile : fileList){
//                file = dataFile;
//                setMessage("Loading document from: " + dataFile.getAbsolutePath());
//                dbController.addDocument(dbController.getCurrentDb(), dataFile, dataSourceName);
//            }
//        }
//        return null;
//    }
}
